package com.szbmyoubao.app.utils

import android.graphics.Color
import android.text.SpannableStringBuilder
import android.text.style.AbsoluteSizeSpan
import android.text.style.StyleSpan
import androidx.core.text.inSpans
import com.szbmyoubao.app.view.span.RadiusBackgroundSpan

/**
 * @author ellecity06
 * @time 2024/11/6 10:23
 * @des
 */

public inline fun SpannableStringBuilder.radiusBackground(
    color: Int,
    mRadius: Int, textColor: Int = Color.WHITE, textSize: Float = 10f,
    builderAction: SpannableStringBuilder .() -> Unit
): SpannableStringBuilder = inSpans(
    RadiusBackgroundSpan(color, mRadius, textColor, textSize),
    builderAction = builderAction
)

public inline fun SpannableStringBuilder.textStyle(
    size: Int,
    style: Int? = null,
    builderAction: SpannableStringBuilder .() -> Unit
): SpannableStringBuilder = if (style == null) inSpans(
    AbsoluteSizeSpan(size),
    builderAction = builderAction
) else inSpans(
    AbsoluteSizeSpan(size),
    StyleSpan(style),
    builderAction = builderAction
)